ShowTable of Contents
Overview
The Expeditor Client for Desktop may be paired with additional components to provide synchronization services. Most commonly, the client is paired with an IBM WebSphere Portal server. The server allows delivery of managed settings (preferences) to the client as well as delivery of Composite Applications.
Synchronizing Programmatically
Synchronization can be accomplished using the SyncManager.
private static Logger logger = Logger.getLogger(SyncSampleManager.class
.getName());
private static final SyncManager syncManager = SyncManagerFactory
.getSyncManager();
private static SyncJobId jobId;
public static void syncAll() {
try {
jobId = syncManager.syncAll(SyncManager.NORMAL_PRIORITY_FILTERNAME);
} catch (SyncException e) {
logger.log(Level.SEVERE, "Error syncing using "
+ SyncManager.NORMAL_PRIORITY_FILTERNAME, e);
}
}
To sync individual services, a URI may be supplied to the SyncManager. The default URIs when Portal is used are CAICatalog and CAIHierarchy.
public static void sync(String uri) {
try {
// for clarity, print out the sync units known to the manager
for (String unit : syncManager.getSyncUnitUris()) {
logger.info("Found Sync Unit " + unit);
}
jobId = syncManager.sync(new String[] { uri }, true);
} catch (SyncException e) {
logger.log(Level.SEVERE, "Error syncing", e);
}
}
Receiving Synchronization Events
It may be beneficial for other plugins to complete work based on synchronization events such as synchronization having just completed. Again, the SyncManager can be used. First add a listener and then create code to handle the received event. Both tasks are shown below.
// listen for events from synchronization
syncManager.addSyncEventListener(getDefaultListener());
private static SyncEventListener getDefaultListener() {
return new SyncEventListener() {
@Override
public void receive(SyncEvent event) {
logger.info("Sync Event Received "
+ event.getEventType().toString());
if (event.getEventContext() instanceof JobContext) {
JobContext context = (JobContext) event.getEventContext();
// check if the sync job we submitted matches the
// event's job id and the event has completed
if (jobId.getId().equals(context.getJobId().getId()) &&
event.getEventType() == EventType.SYNC_COMPLETED_EVENT) {
logger.info("User submitted synchronization has completed");
}
}
// see infocenter for additional details
// http://publib.boulder.ibm.com/infocenter/ledoc/v6r2/index.jsp?topic=/com.ibm.rcp.tools.doc.appdev/dataaccess_developingsyncmanagerapplogic.html
}
};
}
The above code listens for all synchronization events and logs
all the event's names such as SyncStarted or SyncCompleted. But the inner block uses the SyncJobId of the completed event to selectively find the actual synchronization job that was submitted. This is done by comparing the SyncEvent's SyncJobId ID with the SyncJobId that was obtained when the
jobId =
syncManager.sync(
new String[] { uri },
true); was called. By comparing the SyncJobId IDs, you can do work only when that specific job has started, completed, or encountered an error.
Because of the way the synchronization code functions, it's likely much less error prone to simply call the syncAll method rather than individual SyncUnit URIs and listen for that job to complete. If you were to submit an incorrect (non-subordinate) URI, you'd find that the synchronization simply never occurs. For this reason, syncAll is preferred.
Synchronization Details
When the Client for Desktop is paired with a Portal server, the synchronization feature immediately activates. Once the user updates the Home Portal Account preference page, even if the Portal server is unavailable, the user should see the synchronization icon in the launcher (open button). The button can be removed programmatically as demonstrated in the sample code.
private static final String SYNCUI_ACTIVITY_ID = "com.ibm.rcp.syncui.activity.showSyncUI";
public static void updateEnablement(boolean enabled) {
IWorkbenchActivitySupport support = PlatformUI.getWorkbench()
.getActivitySupport();
IActivityManager manager = support.getActivityManager();
Set s = new HashSet(manager.getEnabledActivityIds());
if (enabled) {
s.add(SYNCUI_ACTIVITY_ID);
} else {
s.remove(SYNCUI_ACTIVITY_ID);
}
support.setEnabledActivityIds(s);
}
Using the synchronization launcher allows the user to manually synchronize with the back-end. There are some finer points of synchronization that should be noted:
Synchronization updates may not be immediate. Users may notice a delay of up to one minute before seeing a Composite Application change in the UI despite changes having been made to the back-end server. This is due to caching on the client side. To compensate for this delay, end users should use the "Reload Application" button.
Portal administrators can reduce the cache timeout by specifying a different value using the portal.app.cache.expiration key in the WP ConfigService resource. The default is 60 seconds.
environment provider.
An inability to synchronize on startup has been resolved with APAR LO53899. Contact support regarding fix availability. Users on Expeditor 6.2.2 fix pack 1 will have this fix provided via the fix pack. Users can also elect to receive a prompt to immediately synchronize when the platform starts, which forces immediate synchronization during startup of older clients.